/**********************************************************************************
// Sound Header File
// 
// Creation:	22 Oct 2007
// Updated:		27 Set 2009
// Compiler:	Visual Studio 2008
//
// Notes:		Provide sound playback in games
//
**********************************************************************************/

#ifndef _ANABELE_SOUND_H_
#define _ANABELE_SOUND_H_

/**********************************************************************************/
#include <dsound.h>
#include "WindowsGame.h"

/**********************************************************************************/
// Global Constants and Enumerations

// maximum number of sounds (size of the array)
#define MAXSOUNDS 32

// sound state constants
enum SoundState {SoundNull=0, SoundLoaded=1, SoundPlaying=2, SoundStoped=3};

/**********************************************************************************/
// Type Definitions

typedef struct SoundType
{
	LPDIRECTSOUNDBUFFER buffer;			// directsound buffer
	int state;							// state of the sound
	int rate;							// playback rate
	int size;							// size of sound
	int id;								// id number of the sound
} PCMSound;

/**********************************************************************************/

class DLL Sound
{
private:
	LPDIRECTSOUND lpDS;						// directsound interface pointer
	PCMSound soundFX[MAXSOUNDS];			// array of sound buffers
	int numSoundFX;							// number of sounds allocated in the array
	
public:
	Sound();								// default constructor
	~Sound();								// destructor

	bool Initialize();						// initialize directsound engine
	int  Load(char * filename);				// load a wave file into an empty buffer of the array
	bool Play(int id, int flags);			// play the sound at position id
	bool Stop(int id);						// stop the playing sound
	bool Volume(int id, int vol);			// change volume of the sound
	bool Frequency(int id, int freq);		// change the playback frequency
	bool Pan(int id, int dir);				// change the pan of the sound
	bool Playing(int id);					// return playing status of the sound
};

/**********************************************************************************/

#endif